package com.bill.gaty.mfidelity.beans;

import java.io.Serializable;
 
import java.util.LinkedHashMap;
import java.util.List;
 
import android.util.Log;

import com.bill.gaty.mfidelity.dto.GtfDate;
import com.bill.gaty.mfidelity.dto.GtfResponse;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
 
 
public class Gtf implements Serializable {
/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
private long id;
 
private GtfDate savedate;
private GtfDate lastUpdate;
private String jsonData;
private String votreNom;
private String nomDeVotreAmi;
private String reponse;
@Override
public String toString() {
	return "Gtf [id=" + id + ", savedate=" + savedate + ", lastUpdate="
			+ lastUpdate + ", jsonData=" + jsonData + ", votreNom=" + votreNom
			+ ", nomDeVotreAmi=" + nomDeVotreAmi + ",reponse="+reponse+"]";
}
public String getReponse() {
	return reponse;
}
public void setReponse(String reponse) {
	this.reponse = reponse;
}
public String getVotreNom() {
	return votreNom;
}
public void setVotreNom(String votreNom) {
	this.votreNom = votreNom;
}
public String getNomDeVotreAmi() {
	return nomDeVotreAmi;
}
public void setNomDeVotreAmi(String nomDeVotreAmi) {
	this.nomDeVotreAmi = nomDeVotreAmi;
}
public Gtf() {
	super();
	// TODO Auto-generated constructor stub
}
public long getId() {
	return id;
}
public void setId(long id) {
	this.id = id;
}
public Gtf(String jsonData) {
	super();
	this.jsonData = jsonData;
	this.lastUpdate=new GtfDate();
	this.savedate=new GtfDate();
}
public GtfDate getSavedate() {
	return savedate;
}
public void setSavedate(GtfDate savedate) {
	this.savedate = savedate;
}
public GtfDate getLastUpdate() {
	return lastUpdate;
}
public void setLastUpdate(GtfDate lastUpdate) {
	this.lastUpdate = lastUpdate;
}
public String getJsonData() {
	return jsonData;
}
public void setJsonData(String jsonData) {
	this.jsonData = jsonData;
}
public LinkedHashMap<Integer,GtfResponse> toGtfResponseMap(){
	try{
	Gson g=new Gson();
	java.lang.reflect.Type collectionType = new TypeToken< List<GtfResponse>>(){}.getType();
	  	  
	 List<GtfResponse> li = g.fromJson(getJsonData(),collectionType);
	 LinkedHashMap<Integer,GtfResponse> m=new LinkedHashMap<Integer, GtfResponse>();
	 for (GtfResponse gtfResponse : li) {
		m.put(gtfResponse.getNumero(), gtfResponse);
		return m;
	}
	}catch (Exception e) {
		// TODO: handle exception
		Log.e("toGtfResponse_Exception",e.getMessage());
	}
	  return null; 
}
}
